const Router = require("@koa/router");
const router = new Router();
const {
  updateBackup,
  addBackup,
  deleteBackup,
  queryAllData
} = require('../controller/backup')

router.get("/getAllBackup", async (ctx) => {
  const { page, pageSize } = ctx.request.body
  ctx.body = await queryAllData({
    page,
    pageSize
  })
});
// 增
router.post("/addBackup", async (ctx) => {
  ctx.body = await addBackup(ctx.request.body)
});
// 改
router.post("/updateBackup/:id", async (ctx, next) => {
  ctx.body = await updateBackup(ctx.request.body, ctx.params.id)
});
// 删除
router.delete("/delete/:id", async (ctx, next) => {
  ctx.body = await deleteBackup(ctx.params.id)
});
module.exports = router;
